# dmitry.a.konovalov@gmail.com dmitry.konovalov@jcu.edu.au
#We don't need to clean up when we're making these targets
NODEPS:=clean

# ISSUE!!! order of compiling is not fix and .mod may not be ready when needed
#SRCS  := sys_setup_mod.f95 dbg_mod.f95 test_mod.f95
SRCS  := sys_setup_mod.f95 dbg_mod.f95 test_mod.f95 vec_mod.f95 vec_factory.f95 grid_mod.f95 \
  func_factory.f95
SRCS  := $(addprefix $(SRC_DIR)/, $(SRCS))
# the rest of src files
#Find all the source files in the src directory
SRCS2  := $(wildcard $(SRC_DIR)/*.$(SRC_EXT))
SRCS += $(SRCS2) 
OBJS  := $(SRCS:.$(SRC_EXT)=.o)
OBJS  := $(notdir $(OBJS))
OBJS  := $(addprefix $(OBJ_DIR)/, $(OBJS))
# [26-11-2012] given up on generating dependencies; too hard
#DEPS  := $(OBJS:.o=.d)
MODS  := $(OBJS:.o=.mod)

$(TRGT_LIB) : $(OBJS) $(MODS)
	@echo "(TRGT_LIB) : (OBJS)"
	@echo "  TO  =(TRGT_LIB)=" "$@"
	@echo "  FROM=(OBJS)=" "$<"
	ar cr ${TRGT_LIB} ${OBJS} 
	ranlib ${TRGT_LIB}
	@echo "  ok"

    
#This rule does the compilation
$(OBJ_DIR)/%.o $(OBJ_DIR)/%.mod:  $(SRC_DIR)/%.$(SRC_EXT) 
	@echo ".o .mod:  .(SRC_EXT)"
	@echo "  TO  =.o.mod=" "$@"
	@echo "  FROM=.(SRC_EXT)=" "$<"
	${CF} $(CFLAGS) -c $< -o $@ -J $(OBJ_DIR) 
	@echo "  ok"; 


